<template>
    <view class="page"> 
    <form @submit="submit">
        <view class="xb-form-cell">
           <input class="xb-input" placeholder="" placeholder-class=""></input>
        </view>
 <view class="xb-form-cell">
           <input class="xb-input" placeholder="" placeholder-class=""></input>
           <button viliable="isviliable" @click="sendcode" placeholder="" placeholder=class="">{{btncodetext}}</button>
        </view>
        <view class="xb-button-cell">
        <button class="xb-button" @click="create"></button>
        </view>



        </form>
    </view>
</template>

<script>
	import pageHead from '../../../components/page-head.vue'
    import {mapActions,mapState,mapMutations,mapGetters} from 'vuex'
    export default {
    computed: {
              ...mapGetters([''])
         },
        components:{
            pageHead,

        },
        data(){ 
            return {
                inval:null;
            btncodetext:'',
                isviliable:true;
                times:60;
                formdata:{

                }
            }

        },
        methods: {
            ...mapMutations(['']),
            ...mapActions(['']),

            codecontrol:function(){
                this.times--;
                if(this.times===0){
                    btncodetext='send',
                    this.times=60;
                    isviliable=true;
                    clearInterval(this.inval)
                }else {


                }

            }


            async sendcode:function(e){
            this.inval=setInterval(() => {
  this.codecontrol()
},1000);
            uni.showNavigationBarLoading();
                const res=await sendcode(formdata);
                if(res.success==true){
                uni.hideNavigationBarLoading();

                }else { 
                    uni.hideNavigationBarLoading();
                }
            },

            async create:function(e){
                uni.showNavigationBarLoading();
                const res=await register(formdata);
                if(res.success==true){
                uni.hideNavigationBarLoading();
                }else {
uni.showNavigationBarLoading();
                }


            }
            

        }
    }
</script>

<style scoped>
    @import "../../../common/uni.css";
     @import "../../../common/xb.css";
</style>
